--subdir=DIR Build subdirectory instead of whole project
--prepare=SCRIPT Script to run before build
--libdir=DIR Setup the project with a different libdir
- --destdir=DIR Install the project to an additional destdir
+ --destdir=DIR Install the project to DIR, can be used
+ several times to install to multiple destdirs
-h, --help Display this help
MESON_OPTIONS=()
SUBDIR=.
PREPARE=:
-DESTDIR=""
+DESTDIRS=()
while true; do
case "$1" in
;;
--destdir)
- DESTDIR=$2
+ DESTDIRS+=( $2 )
shift 2
;;
REPO_URL="$1"
COMMIT="$2"
+[[ ${#DESTDIRS[@]} == 0 ]] && DESTDIRS+=( / )
+
CHECKOUT_DIR=$(mktemp --directory)
trap "rm -rf $CHECKOUT_DIR" EXIT
sh -c "$PREPARE"
meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}"
-# Install it to an additional directory e.g., system extension directory
-if [ -n "${DESTDIR}" ]; then
- sudo meson install -C _build --destdir=$DESTDIR
-fi
-
-sudo meson install -C _build
+# Install it to all specified dest dirs
+for destdir in "${DESTDIRS[@]}"; do
+ # don't use --destdir when installing to root,
+ # so post-install hooks are run
+ [[ $destdir == / ]] && destdir=
+ sudo meson install -C _build ${destdir:+--destdir=$destdir}
+done
popd